<layout:sign/>
<body class="hold-transition register-page">
<div class="register-box">
    <div class="register-logo">
        <a href="#"><b>Admin</b>LTE</a>
    </div>
    <div class="register-box-body">
        <p class="login-box-msg">Register a new membership</p>
        <form>
            <div class="form-group has-feedback">
                <input type="text" id="username" class="form-control" placeholder="User name">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="email" id="email" class="form-control" placeholder="Email">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="number" id="phone" class="form-control" placeholder="Phone">
                <span class="glyphicon glyphicon-phone form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" id="password" class="form-control" placeholder="Password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" id="repeat" class="form-control" placeholder="Retype password">
                <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
            </div>
            <div class="row">
                <!--                <div class="col-xs-8">-->
                <!--                    <div class="checkbox icheck">-->
                <!--                        <label>-->
                <!--                            <input type="checkbox"> I agree to the <a href="#">terms</a>-->
                <!--                        </label>-->
                <!--                    </div>-->
                <!--                </div>-->
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="button" id="submit" class="btn btn-primary btn-block btn-flat">Register</button>
                </div>
                <!-- /.col -->
            </div>
        </form>

        <!--        <div class="social-auth-links text-center">-->
        <!--            <p>- OR -</p>-->
        <!--            <a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign up-->
        <!--                using-->
        <!--                Facebook</a>-->
        <!--            <a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign up-->
        <!--                using-->
        <!--                Google+</a>-->
        <!--        </div>-->
        <br>
        <a href="__PUBLIC__/admin/sign/in" class="text-center">I already have a membership</a>
    </div>
    <!-- /.form-box -->
</div>
<!-- /.register-box -->
<script>

    isea.ready(function () {
        $("#submit").click(function () {
            var email = $("#email").val();
            var phone = $("#phone").val();
            var username = $("#username").val();
            var password = $("#password").val();
            var repeat = $("#repeat").val();
            if (repeat !== password) {
                return isea.notify.show('密码前后不一致');
            }
            if (!email) {
                return isea.notify.show('请填写邮箱');
            }
            if (!phone) {
                return isea.notify.show('请填写手机号');
            }
            if (!username) {
                return isea.notify.show('请填写账户名称');
            }
            $.get("__PUBLIC__/admin/sign/up", {
                email: email,
                phone: phone,
                username: username,
                password: password
            }, function (data) {
                if (data.status) {
                    alert(data.message);
                    if (data.redirect) location.href = data.redirect;
                } else {
                    isea.notify.show(data.message);
                }
            });
        });
    });

</script>
</body>

